package com.bxg.bufferdemo;

import java.nio.ByteBuffer;
import java.nio.CharBuffer;

/*缓冲区*/
public class Demo1 {
    public static void main(String[] args) {
        //初始化容量12
        ByteBuffer byteBuffer = ByteBuffer.allocate(12);
        System.out.println("jkdkf");

        /*System.out.println(byteBuffer.position());//位置
        System.out.println(byteBuffer.capacity());//容量
        System.out.println(byteBuffer.limit());//最大限度*/
        byteBuffer.put("abc".getBytes());

      /*  System.out.println(byteBuffer.position());//位置
        System.out.println(byteBuffer.capacity());//容量
        System.out.println(byteBuffer.limit());//最大限度*/
        byteBuffer.flip();
        byteBuffer.mark();//position 0
        System.out.println(byteBuffer.get());
        System.out.println(byteBuffer.get());
        System.out.println(byteBuffer.get());

        byteBuffer.reset(); //position 0
        System.out.println(byteBuffer.get());
        System.out.println(byteBuffer.get());
        System.out.println(byteBuffer.get());

    }
}
